#include "contacts.pb.h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
    contacts::contact conn;
    conn.set_sn(10001);
    conn.set_name("小明");
    conn.set_score(60.5);

    // 持久化数据就放在str对象中，这时候可以对str进行持久化或者网路传输
    //序列化后的数据是二进制类型
    std::string str = conn.SerializeAsString();
    cout << str << endl;

    contacts::contact stu;
    bool ret = stu.ParsePartialFromString(str);
    if (!ret)
    {
        cout << "反序列化失败！" << endl;
        return -1;
    }
    cout << stu.sn() << endl;
    cout << stu.name() << endl;
    cout << stu.score() << endl;

    return 0;
}